<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="Pragma" content="no-cache" />
		<title>我的易安</title>
		<%@ include file="/user_comm.jsp"%>
		<!-- publish_detail_ke.css  -->
		<link rel="stylesheet" href="<%=request.getContextPath()%>/css/publish_detail_ke.css" />
			
		<link href="<%=request.getContextPath()%>/css/prop.css"	type="text/css" rel="stylesheet" />
		<script src="<%=request.getContextPath()%>/js/business.js" language="JavaScript"></script>

	<script language="JavaScript">
	  var selUserId=null;
	  var selCompanyName=null;
	  
	  function previewImage(vSpanId,fileId){
	  	var imgName=vSpanId;
	  	var imgId=$d(fileId).value;
	  	$(imgName).html('');   
		    var newPreview =$(imgName)[0];     
			var imgDiv = document.createElement("div");
			document.body.appendChild(imgDiv);
			imgDiv.style.width = "100%";
	        imgDiv.style.height = "100%";   
	        imgDiv.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod = scale)";      
	        imgDiv.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgId;
			newPreview.appendChild(imgDiv);	
	  }
	
		var checkUserFlag=true;
		var checkSeqFlag=true;
		function carrierTypeChange(){
			if($d("carrierType").value=="1"){
				$d("lb_carrierNo").innerHTML="柜&nbsp;&nbsp;&nbsp;号：";
				$d("tr_size").style.display="block";
				//$d("lb_carrierSize").style.display="block";
				//$d("carrierSize").style.display="block";
			}else{
				$d("lb_carrierNo").innerHTML="车&nbsp;牌&nbsp;号：";
				$d("tr_size").style.display="none";
				//$d("lb_carrierSize").style.display="none";
				//$d("carrierSize").style.display="none";
			}
		}
	
		//inputFlag 是否为手动输入的账户代码
		function checkUserId(userIdVal,inputFlag){
		    checkUserFlag=false;
			$d("recvCompanyid").value = "";
			if(userIdVal==""){
				//$d("recvUsername").innerHTML="请输入收货方账户代码";
				$d("recvUsername").innerHTML="";
				return;
			}
			
			var index=userIdVal.indexOf("-");
			if(index==-1){
				$d("recvUsername").innerHTML="收货方账户代码不正确";
				return;
			}else{
				var strArr=userIdVal.split("-");
				if(strArr.length==2){
					var params = {userIdVal:userIdVal};
					$.ajax({type: "POST",
						   dataType: "json",
					       url: "ajaxUser_checkUserId.do",
					       data: params,
					       async: true,
					       success: function(result){
							 if(result.retcode == "0001"){
							  	checkUserFlag=true;
							 	$d("recvUsername").innerHTML=result.companyInfo.companyName;
							 	$d("recvCompanyid").value = result.companyInfo.companyId;
								$d("txtRecvUserid").value=result.userInfo.userId;
							 }else{
							 	recvUsername.innerHTML=result.retmsg;						 	
							 }
						  }
						},"json");
				}else{
					$d("recvUsername").innerHTML="不存在的收货方";
				}
			}
		}
		
		function checkValid(txtValidate){
			var seqId=txtValidate.value;
			if(seqId==""){
				$d("seqIdError").innerHTML="请输入封条号码";
				return;
			}
			var params = {
					seqId:seqId
					};
			$.ajax({type: "POST",
			       url: "ajax_findValid.do",
			       data: params,
			       async: true,   
			       success: function(result){
					 var validate=result.validate;
					 if(validate != null){
					  	var status=validate.status;
					  	if(result.retcode == "0000"){
					  		seqIdError.innerHTML="";
					  		checkSeqFlag=true;
					  	}else{
					  		checkSeqFlag=false;
					  		seqIdError.innerHTML=result.retmsg;
					  	}
					 }else{
					 	checkSeqFlag=false;
					 	seqIdError.innerHTML="封条不存在";
					 }
				  }
				},"json");
		}
		
		//----------------通讯录----------------
		function showContact(){
			var retArr  = new Array();
			var winFeatures="dialogHeight:600px;dialogWidth:800px;edge:Raised;center:Yes;help:No;resizable:No;status:No;";
			var url = "listContact.do";
			retArr = window.showModalDialog(url,"", winFeatures);
			if(retArr ==null || (!retArr)){
				return false;
			}else{
				//只返回userId,其他信息再实时查询
				//var strArr=retArr[0].split("-");
				$d("txtRecvUserid").value = retArr[0].toString();
				//$d("recvUsername").innerHTML = retArr[1].toString(); //公司名称
				//实时查询，防止关联账户已被删除
				checkUserId(retArr[0].toString(),false);
				return true;
			}
		}
		
		function selectRow(memberId,userId,companyName){
			var arrSon = document.getElementsByName('chkSon');
		 	var curChkbox = document.getElementById(memberId);
		 	if(curChkbox.checked==true){
			 	for(var i=0; i<arrSon.length; i++) {
			 		if(arrSon[i].value != memberId){
			     		arrSon[i].checked = false;
			     	}
			 	}
			 	curChkbox.checked=true;
			 	selUserId=userId;
				selCompanyName=companyName;
		 	}else{
		 		selUserId='';
				selCompanyName='';
			}
		}
		
		function selectOK()
		{
			if(selUserId=='' || selUserId==null)
			{
				alert("请选择收货方账户");
				return;
			}
			var obj=new Array(selUserId,selCompanyName);
			window.returnValue = obj;
			window.close();
		}
		
		function mycallbackform(v,m,f){
			alert("call back");
			if(v != undefined)
			$.prompt(v +' ' + f.alertName);
		}
		
		function checkSubmit(){
			if(checkUserFlag==false){
				alert("请输入正确的收货方");
				return false;
			}
			
			if(checkSeqFlag==false){
				alert("该封条不可用，请输入其他封条号码");
				return false;
			}
			$('#busiInfo_add').submit();
			return true;
		}
	</script>

	</head>
	<body>
		<%@ include file="/user_top.jsp"%>
		<div class="realCer">
			<!--导航-->
			<!--主体部分start-->
			<div class="realMain clearfix mt10">
				<%@ include file="/user_menu.jsp"%>
				<div class="realRight ml10 Buyer">
					<div class="mybox">
						<div class="mytit">
							货物发送业务单
						</div>
						<div class="con Orbuy">
							<s:form name="formpage" action="busiInfo_add" namespace="/"
								method="POST" enctype="multipart/form-data">
								<div align="left">
									<%@ include file="/messages.jsp"%>
									<s:token>
									</s:token>
									<s:hidden name="busiInfo.busiNo"
										value="%{#request.busiInfo.busiNo}" />
									<table class="basicInfor">
										<tr>
											<th>
												发货方：
											</th>
											<td class="fc9">
												&nbsp;${sendUsername }
											</td>
										</tr>
										<tr>
											<th>
												<label for="txtRecvUserid">
													收货方：
												</label>
											</th>
											<td class="fc9">
												&nbsp;
												<span class="at_text t_1_d"> <input
														id="txtRecvUserid" name="busiInfo.recvUserid" type="text"
														size="30" maxlength="40" value="${busiInfo.recvUserid }"
														onclick="javascript:showContact();" /> <!-- onblur="checkUserId(this.value,true);" -->
												</span> &nbsp;
												<a target="_self" href="#"
													onclick="javascript:showContact();">选择收货方</a>
											</td>
										</tr>
										<tr id="tr_recvInfo">
											<!-- style="display:none" -->
											<th>
											</th>
											<td>
												&nbsp;
												<input type="hidden" id="recvCompanyid"
													name="busiInfo.recvCompanyid"
													value="${busiInfo.recvCompanyid }" />
												<span id="recvUsername" />
											</td>
										</tr>

										<tr>
											<th>
												<label for="seqId">
													封条号：
												</label>
											</th>
											<td>
												&nbsp;
												<span class="at_text t_1_d"><input
														name="busiInfo.seqId" id="seqId" type="text" size="30"
														maxlength="40" value="${busiInfo.seqId }" /> <!-- onblur="checkValid(this);" -->
													<span id="seqIdError"></span> </span>
											</td>
										</tr>
										<tr>
											<th>
												加载类型：
											</th>
											<td>
												&nbsp;
												<select name="busiInfo.carrierType" id="carrierType"
													style="width: 202px" onchange="carrierTypeChange();">
													<option value="1">
														集装箱
													</option>
													<option value="2">
														货&nbsp;&nbsp;&nbsp;车
													</option>
												</select>
											</td>
										</tr>
										<tr>
											<th>
												<label id="lb_carrierNo" for="carrierNo">
													柜&nbsp;&nbsp;&nbsp;&nbsp;号：
												</label>
											</th>
											<td>
												&nbsp;
												<span class="at_text t_1_d"><input id="carrierNo"
														name="busiInfo.carrierNo" id="carrierNo" size="30"
														type="text" maxlength="40" value="${busiInfo.carrierNo}"
														title="*必填" /> </span>
											</td>
										</tr>
										<tr id="tr_size">
											<th>
												<label id="lb_carrierSize" for="carrierSize">
													货柜尺寸：
												</label>
											</th>
											<td>
												&nbsp;
												<span class="at_text t_1_d"><input
														name="busiInfo.carrierSize" id="carrierSize" type="text"
														size="30" maxlength="40" value="${busiInfo.carrierSize}" />
												</span>
											</td>
										</tr>
										<tr>
											<th>
												<label for="goodsNum">
													货物数量：
												</label>
											</th>
											<td>
												&nbsp;
												<span class="at_text t_1_d"><input
														name="busiInfo.goodsNum" type="text" id="goodsNum"
														size="30" title="*必填" value="${busiInfo.goodsNum}" /> </span>
												<!--<em>*</em>-->
											</td>
										</tr>
										<tr>
											<th>
												<label for="goodsInfo">
													货物描述：
												</label>
											</th>
											<td>
												&nbsp;
												<span class="at_text t_1_d"> <input id="goodsInfo"
														name="busiInfo.goodsInfo" type="text"
														style="width: 380px;" maxlength="40" size="30"
														value="${busiInfo.goodsInfo}" title="*必填" /> </span>
												<!--<em>*</em>-->
											</td>
										</tr>

										<tr>
											<th valign="top">
												<label for="googsDetail">
													详细信息：
												</label>
											</th>
											<td>
												<textarea name="busiInfo.goodsDetail" id="googsDetail"
													cols="50" rows="5" style="width: 500px; height: 80px;">${busiInfo.goodsDetail }</textarea>
											</td>
										</tr>
										<tr>
											<td align="right" valign="top">
												上传图片：
											</td>
											<td>
												<table align="center" width="600">
													<tr>
														<td>
															<div>
																<!-- 	
										<span> 
										<div style="position: absolute; right: 35px; color: #f60;">
											上传1200px*1200px以上的图片，即可在宝贝详情页面提供图片放大功能
										</div>
											<div id="J_UploadPicTab" class="upload-manager upload-pic">
												  -->
																<div class="panel panel-local">
																	<div class="pic-manager">
																		<!-- 
															<div class="side">
																<div></div>
																<ul>
																	<li class="s1">
																		<a href="javascript:;">d1</a>
																	</li>
																	<li class="s2">
																		<a href="javascript:;">d2</a>
																	</li>
																	<li class="s3">
																		<a href="javascript:;">d3</a>
																	</li>
																	<li class="s4">
																		<a href="javascript:;">d4</a>
																	</li>
																	<li class="s5">
																		<a href="javascript:;">d5</a>
																	</li>
																</ul>
															</div>
															 -->
																		<div class="main">
																			<input type="hidden" class="J_FirstPicField" />
																			<ul id="J_PanelLocalList">
																				<li>
																					<input type="hidden" class="J_PicUrl"
																						name="picUrl1" id="picUrl1" value="" />
																					<input name="image_pos" type="hidden" value="1" />
																					<span class="preview" id="preview1"></span>
																					<span class="upload"><a href="javascript:;">
																							<s:file name="myfile" id="myfile1"
																								onchange="previewImage('#preview1','myfile1');" />
																					</a> </span>
																					<!-- 
																		<span class="act"> <span class="moveleft">左移</span>
																			<span class="moveright">右移</span> <span class="del">删除</span>

																		</span>
																		 -->
																				</li>
																				<li>
																					<input type="hidden" class="J_PicUrl"
																						name="picUrl2" value="" />
																					<input name="image_pos" type="hidden" value="2" />
																					<span class="preview" id="preview2"></span>
																					<span class="upload"><a href="javascript:;">
																							<s:file name="myfile" id="myfile2"
																								onchange="previewImage('#preview2','myfile2');" />
																					</a> </span>
																				</li>
																				<li>
																					<input type="hidden" class="J_PicUrl"
																						name="picUrl3" value="" />
																					<input name="image_pos" type="hidden" value="3" />
																					<span class="preview" id="preview3"></span>
																					<span class="upload"><a href="javascript:;">
																							<s:file name="myfile" id="myfile3"
																								onchange="previewImage('#preview3','myfile3');" />
																					</a> </span>
																				</li>
																				<li>
																					<input type="hidden" class="J_PicUrl"
																						name="picUrl4" value="" />
																					<input name="image_pos" type="hidden" value="4" />
																					<span class="preview" id="preview4"></span>
																					<span class="upload"><a href="javascript:;">
																							<s:file name="myfile" id="myfile4"
																								onchange="previewImage('#preview4','myfile4');" />
																					</a> </span>
																				</li>
																				<li>
																					<input type="hidden" class="J_PicUrl"
																						name="picUrl5" value="" />
																					<input name="image_pos" type="hidden" value="5" />
																					<span class="preview" id="preview5"></span>
																					<span class="upload"><a href="javascript:;">
																							<s:file name="myfile" id="myfile5"
																								onchange="previewImage('#preview5','myfile5');" />
																					</a> </span>
																				</li>

																				<li>
																					<input type="hidden" class="J_PicUrl"
																						name="picUrl6" value="" />
																					<input name="image_pos" type="hidden" value="6" />
																					<span class="preview" id="preview6"></span>
																					<span class="upload"><a href="javascript:;">
																							<s:file name="myfile" id="myfile6"
																								onchange="previewImage('#preview6','myfile6');" />
																					</a> </span>
																				</li>
																			</ul>
																		</div>
																	</div>
																	<div class="msg">
																		<span class="orange1 ml5">
																			您的图片空间剩余容量为${request.leftSpaceSize }M。 单个图片大小不能超过500K
																		</span>
																	</div>
																</div>
																<!-- </div> </span> -->
															</div>
														</td>
													</tr>
												</table>
											</td>
										</tr>
										<tr>
											<td></td>
											<td>
												<a href="javascript:checkSubmit();" class="at_but b_1_y"
													id="reg_sub"><u></u>确认</a>
											</td>
										</tr>
									</table>
								</div>

								<div id="div_contact" style="display: none">
										<table>
											<tr>
												<td width="200" valign="top">
													<div style="border: 1px solid #c5ddf6; padding: 5px;">
														<span id="spanGroups"> </span>
													</div>
												</td>
												<td width="650" valign="top">
													<!-- 联系人列表 start -->
													<div id="div_memberlist" style="display: block;">
														<table class="favorRwList mt5" id="tb_memberList">
														</table>
													</div>
													<!-- 联系人列表 end -->
												</td>
											</tr>
										</table>
								</div>
							</s:form>
						</div>
					</div>
					<div>
					</div>
					<!--主体部分end-->
				</div>
			</div>
		</div>
		<!--底部 start-->
		<%@ include file="/user_button.jsp"%>
		<script type="text/javascript">
	new business();
</script>
		<!--底部end-->
	</body>
</html>

